﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace SoftwareApproach.TestingExtensions.Tests
{
    [TestClass]
    public class AssertHelperTests
    {
        public TestContext TestContext { get; set; }

        [TestMethod]
        public void AssertHelper_HandleFailTest()
        {
            bool exceptionCaught = false;
            try
            {
                AssertHelper_Accessor.HandleFail("TestAssertion", "Test Message: {0}", "Test Param");
            }
            catch (AssertFailedException afe)
            {
                exceptionCaught = true;
                Assert.IsTrue(afe.Message.Contains("TestAssertion"));
                Assert.IsTrue(afe.Message.Contains("Test Message"));
                Assert.IsTrue(afe.Message.Contains("Test Param"));
            }

            if (!exceptionCaught) Assert.Fail("HandleFail did not throw an exception as expected.");
        }

        [TestMethod]
        public void AssertHelper_AppendMessageTest()
        {
            string actual = AssertHelper_Accessor.AppendMessage("SourceString", "SomeMessage: {0}", "SomeParam");
            string expected = "SomeMessage: SomeParam SourceString";
            Assert.AreEqual(expected, actual);
        }
    }
}
